package ua.kharkov.khpi.tarasenko.bach.dao.core.item;

import java.util.ArrayList;
import java.util.List;

import ua.kharkov.khpi.tarasenko.bach.core.db.EShopDataStoreException;

/**
 * Interface for DAO for working with datasource with items in.
 * 
 * @author oleksandr
 * 
 */
public interface ItemDAO {

	/**
	 * Finds item by it's id.
	 * 
	 * @param id
	 *            - item's id to find.
	 * @return ItemDTO.
	 * @throws EShopDataStoreException
	 *             if error occurred during execution.
	 */
	public ItemDTO findItemById(int id) throws EShopDataStoreException;

	/**
	 * Finds all items.
	 * 
	 * @return all items.
	 * @throws EShopDataStoreException
	 *             if error occurred during execution.s
	 */
	public ArrayList<ItemDTO> findAllItems()
			throws EShopDataStoreException;

	/**
	 * Adds new item.
	 * 
	 * @param item
	 *            - item to add.
	 * @return rowsAdded - number of added rows.
	 * @throws EShopDataStoreException
	 *             if error occurred during execution.
	 */
	public int addItem(ItemDTO item) throws EShopDataStoreException;

	/**
	 * Updates item. Id should be specified in param's object.
	 * 
	 * @param item
	 *            - item to update.
	 * @return
	 * @throws EShopDataStoreException
	 *             if error occurred during execution.
	 */
	public int updateItem(ItemDTO item) throws EShopDataStoreException;

	/**
	 * Finds all items by given category.
	 * 
	 * @return all items in given category
	 * @throws EShopDataStoreException
	 *             if error occurred during execution.
	 */
	public ArrayList<ItemDTO> findItemsByCategory(int categoryId)
			throws EShopDataStoreException;

	/**
	 * Delete item.
	 * 
	 * @param itemId
	 *            - id of item to delete.
	 * @return rowsDeleted - number of deleted rows.
	 * @throws EShopDataStoreException
	 *             if error occurred during execution.
	 */
	public int deleteItem(int itemId) throws EShopDataStoreException;
	
	public List<ItemDTO> getTopNAvailableProducts(int n, Integer[] exceptProds) throws EShopDataStoreException;
}
